{% extends "blogs/admin/base_blog.html" %}

{% block current_action %}
    {% if post %}
        Edit post
    {% else %}
        Add post
    {% endif %}
{% endblock %}

{% block content %}
    {% if post.is_published %}
        <p><em>This post was published on {{ post.pub_date }} by {{ post.byline }}. Last modified on {{ post.mod_date }} by {{ post.mod_user }}.</em></p>
    {% else %}{% if post %}
        <p><em>This post has not been published yet.</em></p>
    {% endif %}{% endif %}
    <p class="small">* denotes required fields</p>
    <form action="" method="post">
        {% if back %}<input type="hidden" name="back" value="{{ back }}" />{% endif %}
        <fieldset  class="module ">
            <dl>
                {% for field in form %}
                    <dt>{{ field.label_tag }}: {% if field.field.required %}*{% endif %}</dt>
                    <dd>{{ field }}</dd>
                    {% if field.help_text %}<dd>{{ field.help_text }}</dd>{% endif %}
                    {% if field.errors %}<dd class="myerrors">{{ field.errors }}</dd>{% endif %}
                {% endfor %}
            </dl>
        </fieldset >
        <div class="submit-row">
            {% if post %}<p class="float-left"><a class="deletelink" href="delete/">Delete</a></p>{% endif %}
            {% if post.is_published %}
                <input class="default" type="submit" value="Save" />
            {% else %}
                <input class="default" type="submit" value="Publish" />
                <input type="submit" name="_save" value="Save Draft" />
            {% endif %}
            <input type="submit" name="_continue" value="Save and Continue" />
        </div>
        {% if not post %}
            <script type="text/javascript">
                document.getElementById("id_title").onkeyup = function() { 
                    var e = document.getElementById("id_slug"); 
                    e.value = URLify(document.getElementById("id_title").value, 50);
                }; 
            </script>
        {% endif %}
    </form>
{% endblock %}